<style lang="less">
@import '../../../styles/common.less';
</style>

<template>
    <Card style="height:800px">
        <Card>
            <header>
                <span>身份证号:</span>
                <Input v-model="reviewCondition.custIdNumber" style="width: 150px" />
                 <span style="width: 200px;margin-left: 20px;">合同编号:</span>
                <Input v-model="reviewCondition.contractId" style="width: 150px" />
                 <span style="width: 200px;margin-left: 20px;">还款计划编号:</span>
                <Input v-model="reviewCondition.planId" style="width: 150px" />
                <Button type="primary" @click="listQuery"  style="margin-left: 15px;">搜索</Button>
                <Button type="primary" @click="reset"  style="margin-left: 15px;">重置</Button>
            </header>
        </Card>
        <Card>
            <Row type="flex" justify="center" align="middle" class="list-query">
                <Table :columns="columnsDetail" :data="dataDetail" style="width: 100%;"></Table>
            </Row>
            <div style="margin-top: 36px;text-align: center;">
                <Page :total="reviewCondition.total" :current="reviewCondition.pageNum" :page-size="reviewCondition.pageSize" size="small" show-elevator show-sizer show-total @on-change="pageChange" @on-page-size-change="sizeChange"></Page>
            </div>
        </Card>
    </Card>
</template>

<script>
import expandRow from './penalty-adjustment-verify-tableExpand.vue'
export default {
  name: 'mutative-router',
  components: { expandRow },
  data () {
    return {
      reviewCondition: {
        pageNum: 1,
        pageSize: 10,
        total: 0,
        custIdNumber: '',
        custName: '',
        contractId: '',
        planId: ''
      },
      columnsDetail: [
        {
          type: 'expand',
          width: 30,
          render: (h, params) => {
            return h(expandRow, {
              props: {
                row: params.row
              }
            })
          }
        },
        {
          type: 'index',
          title: '序号',
          width: 60
        },
        {
          title: '申请编号',
          key: 'loanId',
          align: 'center',
          width: 150,
          className: 'tbake'
        },
        {
          title: '还款计划号',
          key: 'planId',
          align: 'center',
          width: 250,
          className: 'tbake'
        },
        {
          title: '申请日期',
          key: 'applyTime',
          align: 'center',
          width: 100,
          className: 'tbake',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('span', vm.$util.loanModularFormatTime(params.row.applyTime))
            ])
          }
        },
        {
          title: '客户姓名',
          key: 'custName',
          align: 'center',
          width: 90,
          className: 'tbake'
        },
        // {
        //   title: '客户身份证号',
        //   key: 'custCardNo',
        //   align: 'center'
        // },
        // {
        //   title: '期数',
        //   key: 'periods',
        //   align: 'center'
        // },
        {
          title: '管理费',
          key: 'managementFee',
          align: 'center',
          width: 90,
          className: 'tbake'
        },
        {
          title: '罚费1（违约金）',
          key: 'penaltyFee',
          align: 'center',
          width: 100,
          className: 'tbake'
        },
        {
          title: '罚费2（滞纳金）',
          key: 'lateFee',
          align: 'center',
          width: 100,
          className: 'tbake'
        },
        {
          title: '交易类型',
          key: 'tradeType',
          align: 'center',
          width: 100,
          className: 'tbake',
          render: (h, params) => {
            if (params.row.tradeType === '1') {
              return h('span', {
                props: {
                  type: 'span',
                  size: 'small'
                }
              }, '管理费-减免')
            } else if (params.row.tradeType === '2') {
              return h('span', {
                props: {
                  type: 'span',
                  size: 'small'
                }
              }, '罚息1-减免')
            } else if (params.row.tradeType === '3') {
              return h('span', {
                props: {
                  type: 'span',
                  size: 'small'
                }
              }, '罚息2-减免')
            } else if (params.row.tradeType === '4') {
              return h('span', {
                props: {
                  type: 'span',
                  size: 'small'
                }
              }, '管理费-调增')
            } else if (params.row.tradeType === '5') {
              return h('span', {
                props: {
                  type: 'span',
                  size: 'small'
                }
              }, '罚息1-调增')
            } else if (params.row.tradeType === '6') {
              return h('span', {
                props: {
                  type: 'span',
                  size: 'small'
                }
              }, '罚息2-调增')
            }
          }
        },
        {
          title: '交易金额',
          key: 'amount',
          align: 'center',
          width: 100,
          className: 'tbake'
        },
        {
          title: '当前状态',
          key: 'status',
          align: 'center',
          width: 100,
          className: 'tbake',
          render: (h, params) => {
            if (params.row.status === '0') {
              return h('span', {
                props: {
                  type: 'span',
                  size: 'small'
                }
              }, '待审批')
            } else if (params.row.status === '1') {
              return h('span', {
                props: {
                  type: 'span',
                  size: 'small'
                }
              }, '审批成功')
            } else if (params.row.status === '2') {
              return h('span', {
                props: {
                  type: 'span',
                  size: 'small'
                }
              }, '审批拒绝')
            }
          }
        },
        {
          title: '申请人',
          key: 'applyUserName',
          align: 'center',
          width: 80,
          className: 'tbake'
        },
        // {
        //   title: '备注',
        //   key: 'remark',
        //   align: 'center'
        // },
        {
          title: '操作',
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h('Button', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  marginRight: '10px'
                },
                on: {
                  click: () => {
                    this.$Modal.confirm({

                      title: '罚息调整审核',

                      content: '确定通过吗?',

                      okText: '确定',

                      cancelText: '取消',
                      onOk: () => {
                        var vm = this
                        var data = { 'planId': params.row.planId }
                        this.$ajax.post(this.$appContext.marvels_core_financial + 'financial/loan/penaltyAdjustment/service/penaltyAdjustmentAdopt', data).then(re => {
                          var data = re.data
                          var message = data.message
                          this.$Message.info(message)
                          vm.listQuery()
                        }).catch(er => {

                        })
                      }
                    })
                  }
                }
              }, '通过'),
              h('Button', {
                props: {
                  type: 'error',
                  size: 'small'
                },
                on: {
                  click: () => {
                    this.$Modal.confirm({
                      title: '罚息调整审核',

                      content: '确定拒绝吗',

                      okText: '确定',

                      cancelText: '取消',
                      onOk: () => {
                        var vm = this
                        var data = { 'planId': params.row.planId }
                        this.$ajax.post(this.$appContext.marvels_core_financial + 'financial/loan/penaltyAdjustment/service/penaltyAdjustmentRefuse', data).then(re => {
                          var data = re.data
                          var message = data.message
                          this.$Message.info(message)
                          vm.listQuery()
                        }).catch(er => {

                        })
                      }
                    })
                  }
                }
              }, '拒绝')
            ])
          }
        }
      ],
      dataDetail: [
      ]

    }
  },
  computed: {
    avatorImage () {
      return localStorage.avatorImgPath
    }
  },
  created () {
    // 初始化当前页面请求对象实例
    this.$ajax = this.$util.ajax()
  },
  methods: {
    pageChange: function (pageNum) {
      var vm = this
      vm.reviewCondition.pageNum = pageNum
      vm.listQuery()
    },
    sizeChange: function (pageLength) {
      var vm = this
      vm.reviewCondition.pageSize = pageLength
      vm.listQuery()
    },
    listQuery () {
      var vm = this
      this.$ajax.post(this.$appContext.marvels_core_financial + 'financial/loan/penaltyAdjustment/service/penaltyAdjustmentReview', vm.reviewCondition).then(re => {
        var data = re.data
        vm.dataDetail = data.data.list
        vm.reviewCondition.total = data.data.total
      }).catch(er => {

      })
    },
    reset () {
      var vm = this
      vm.reviewCondition.custIdNumber = ''
      vm.reviewCondition.contractId = ''
      vm.reviewCondition.planId = ''
    }

  }
}
</script>
